/**
 * Copyright 2007 Luke Pillow
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.orsomethinglikethat.hinge.asgen;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lpillow
 */
public class ASGenTypeConverter
{
    private final static Map<String, String> j2asTypes;

    static
    {
        j2asTypes = new HashMap<String, String>();

        j2asTypes.put( "java.lang.String", "String" );
        j2asTypes.put( "java.lang.Boolean", "Boolean" );
        j2asTypes.put( "int", "Number" );
        j2asTypes.put( "short", "Number" );
        j2asTypes.put( "float", "Number" );
        j2asTypes.put( "double", "Number" );

        j2asTypes.put( "boolean", "Boolean" );
        j2asTypes.put( "java.lang.Integer", "Number" );
        j2asTypes.put( "java.lang.Short", "Number" );
        j2asTypes.put( "java.lang.Byte", "Number" );
        j2asTypes.put( "java.lang.Byte[]", "flash.utils.ByteArray" );
        j2asTypes.put( "java.lang.Double", "Number" );
        j2asTypes.put( "java.lang.Long", "Number" );
        j2asTypes.put( "java.lang.Float", "Number" );
        j2asTypes.put( "java.lang.Character", "String" );
        j2asTypes.put( "java.lang.Character[]", "String" );
        j2asTypes.put( "java.util.Calendar", "Date" );
        j2asTypes.put( "java.util.Date", "Date" );

        j2asTypes.put( "java.lang.Object", "Object" );
        j2asTypes.put( "java.util.Collection", "mx.collection.ArrayCollection" );
        j2asTypes.put( "java.lang.Object[]", "Array" );
        j2asTypes.put( "java.util.Map", "Object" );
        j2asTypes.put( "java.util.Dictionary", "Object" );
        j2asTypes.put( "org.w3c.dom.Document", "XML" );
    }

    public static String convertJavaType( String javaType )
    {
        return j2asTypes.get( javaType );
    }

}
